package com.ruoyi.ky450.vo;

import com.ruoyi.common.constant.CharConstant;
import com.ruoyi.common.utils.IdentitiesUtils;
import lombok.Data;
import org.apache.commons.compress.utils.Lists;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Data
public class TreeDataVo {
    private String id;
    private Long tableId;
    private String label;
    private List<TreeDataVo> children = Lists.newArrayList();
    private int childrenSize;
    /**
     * 固定设施树：0-所属国家 1-目标类别 2-目标
     * 装备树：1-目标类别 2-目标
     *
     *
     */
    private Integer dataType;

    public TreeDataVo() {
    }

    public TreeDataVo(Long tableId, String label, Integer dataType) {
        this.id = IdentitiesUtils.uuid2() + CharConstant.SPLIT_HG + System.currentTimeMillis();
        this.tableId = tableId;
        this.label = label;
        this.dataType = dataType;
    }

    public void setChildren(List<TreeDataVo> children) {
        this.children = children;
        this.childrenSize = CollectionUtils.isEmpty(children) ? 0 : children.size();
    }
}
